using UnityEditor;

namespace GameToolkit.Editor
{
    [CustomEditor(typeof(NavMeshSource), true), CanEditMultipleObjects]
    public class NavMeshSourceEditor : UnityEditor.Editor
    {
        SerializedProperty m_IsRuntime;

        private void OnEnable()
        {
            m_IsRuntime = serializedObject.FindProperty("m_IsRuntime");
        }

        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            EditorGUI.BeginChangeCheck();
            EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode);
            EditorGUILayout.PropertyField(m_IsRuntime);
            EditorGUI.EndDisabledGroup();
            var dirty = EditorGUI.EndChangeCheck();
            if (dirty)
                serializedObject.ApplyModifiedProperties();
        }
    }
}
